import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { NestExpressApplication } from '@nestjs/platform-express';
import { HttpExceptionFilter} from './exception/http-exception.filter';
import { join } from 'path';
async function bootstrap() {
  const app = await NestFactory.create<NestExpressApplication>(AppModule);
  //自定义状态
  app.useGlobalFilters(new HttpExceptionFilter())
  //配置静态资源
  app.useStaticAssets(join(__dirname, '..', 'public'),{
    prefix:'/public/'
  })
  app.enableCors({
    origin: true, // 或者指定特定的域名，如 'http://example.com'
    methods: 'GET,HEAD,PUT,PATCH,POST,DELETE',
    credentials: true,
  });
  await app.listen(process.env.PORT ?? 3000);
}
bootstrap();
